angular.module('eYe')	
	.factory('safeApply', function($rootScope) {
		return function($scope, fn) {
			var phase = $scope.$root.$$phase;
			if(phase == '$apply' || phase == '$digest') {
				if(fn && (typeof(fn) === 'function')) {
				  fn();
				}
			} 
			else {				
				$scope.$apply(fn);				
			}
		}
	});